#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include"musiclist.h"
#include"qmediaplaylist.h"

enum PageType{
    LIKEPAGE,
    RECENTPAGE,
    LOCALPAGE
};

namespace Ui {
class CommonPage;
}

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

public:
    void setCommonPageUi(const QString& title, const QString& image);
    void setMusicListType(PageType pageType);
    void addMusicToMusicPage(MusicList& musicList);
    void refreshPage(MusicList& musicList);
    void addMusicToPlayList(MusicList& musicList, QMediaPlaylist* playList);
    QString getMusicIdByIndex(const int index);
    void setImageLabel(const QPixmap& pixmap);

signals:
    void updateLikeMusic(bool isLike, QString musicId);
    void playAll(PageType type);
    void playMusicbyIndex(CommonPage* page, int index);

private:
    Ui::CommonPage *ui;

    //歌单列表
    QVector<QString> _musicOfPage; //存放音乐的数组
    PageType _pageType;//标记属于哪个页面
};

#endif // COMMONPAGE_H
